package com.beiding.test.pg;

import com.beiding.sqlbuilder.ConditionUnit;
import com.beiding.sqlbuilder.ConditionUnitHandler;
import com.beiding.sqlbuilder.LogicConnector;

public class LogicConnectorHandler implements ConditionUnitHandler {

    @Override
    public boolean canHandle(ConditionUnit conditionUnit) {
        return conditionUnit instanceof LogicConnector;
    }

    @Override
    public String handle(ConditionUnit conditionUnit) {

        LogicConnector connector = (LogicConnector) conditionUnit;
        switch (connector.getLogicType()) {
            case And:
                return " and ";
            case Or:
                return " or ";
        }
        throw new RuntimeException("不支持连接符:" + connector.getLogicType());
    }
}
